home *** CD-ROM | disk | FTP | other *** search
/ Macintosh Technology Seed 1996 September / Macintosh Technology Seed (September 1996) (CDRM1437020).ISO / pc / qd3d15d6 / 15d6_sdk.exe / QD3D Win32 1.5d6 / Interfaces / QD3DSet.h < prev    next >
C/C++ Source or Header  |  1996-08-21  |  13KB  |  386 lines

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DSet.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:     Set types and routines                                     **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **                                                                             **
  10.  **     Copyright (C) 1992-1996 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                             **
  12.  **                                                                             **
  13.  *****************************************************************************/
  14. #ifndef QD3DSet_h
  15. #define QD3DSet_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #if defined(THINK_C) || defined(__SC__)
  22.     #pragma options(!pack_enums, !align_arrays)
  23.     #pragma SC options align=power
  24. #elif defined(__MWERKS__)
  25.     #pragma enumsalwaysint on
  26.     #pragma align_array_members off
  27.     #pragma options align=native
  28. #elif defined(__PPCC__)
  29.     #pragma options align=power
  30. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  31.     #pragma options enum=int
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif    /* __cplusplus */
  37.  
  38.  
  39. /******************************************************************************
  40.  **                                                                             **
  41.  **                                Set Routines                                 **
  42.  **                                                                             **
  43.  *****************************************************************************/
  44.  
  45. QD3D_EXPORT TQ3SetObject Q3Set_New(
  46.     void);
  47.  
  48. QD3D_EXPORT TQ3ObjectType Q3Set_GetType(
  49.     TQ3SetObject        set);
  50.  
  51. QD3D_EXPORT TQ3Status Q3Set_Add(
  52.     TQ3SetObject         set, 
  53.     TQ3ElementType        type,
  54.     const void             *data);
  55.  
  56. QD3D_EXPORT TQ3Status Q3Set_Get(
  57.     TQ3SetObject         set,
  58.     TQ3ElementType        type,
  59.     void                *data);
  60.  
  61. QD3D_EXPORT TQ3Boolean Q3Set_Contains(
  62.     TQ3SetObject         set,
  63.     TQ3ElementType        type);
  64.  
  65. QD3D_EXPORT TQ3Status Q3Set_Clear(
  66.     TQ3SetObject         set, 
  67.     TQ3ElementType        type);
  68.  
  69. QD3D_EXPORT TQ3Status Q3Set_Empty(
  70.     TQ3SetObject         target);
  71.  
  72. /*
  73.  *  Iterating through all elements in a set
  74.  *
  75.  *  Pass in kQ3ElementTypeNone to get first type
  76.  *  kQ3ElementTypeNone is returned when end of list is reached
  77.  */
  78. QD3D_EXPORT TQ3Status Q3Set_GetNextElementType(
  79.     TQ3SetObject         set,
  80.     TQ3ElementType        *type);        
  81.  
  82.  
  83. /******************************************************************************
  84.  **                                                                             **
  85.  **                                Attribute Types                                 **
  86.  **                                                                             **
  87.  *****************************************************************************/
  88.  
  89. /* 
  90.  *    For the data types listed below, pass in a pointer to it in the _Add 
  91.  *    and _Get calls.
  92.  *
  93.  *    For surface shader attributes, reference counts are incremented on 
  94.  *    the _Add and _Get 
  95.  */
  96.  
  97. typedef enum TQ3AttributeTypes {                /* Data Type                */
  98.     kQ3AttributeTypeNone                =  0,    /* ---------                */
  99.     kQ3AttributeTypeSurfaceUV            =  1,    /* TQ3Param2D                */ 
  100.     kQ3AttributeTypeShadingUV            =  2,    /* TQ3Param2D                 */
  101.     kQ3AttributeTypeNormal                =  3,    /* TQ3Vector3D                 */
  102.     kQ3AttributeTypeAmbientCoefficient    =  4,    /* float                     */
  103.     kQ3AttributeTypeDiffuseColor        =  5,    /* TQ3ColorRGB                */
  104.     kQ3AttributeTypeSpecularColor        =  6,    /* TQ3ColorRGB                */
  105.     kQ3AttributeTypeSpecularControl        =  7,    /* float                    */
  106.     kQ3AttributeTypeTransparencyColor    =  8,    /* TQ3ColorRGB                */
  107.     kQ3AttributeTypeSurfaceTangent        =  9,    /* TQ3Tangent2D              */
  108.     kQ3AttributeTypeHighlightState        = 10,    /* TQ3Switch                 */
  109.     kQ3AttributeTypeSurfaceShader        = 11,    /* TQ3SurfaceShaderObject    */
  110.     kQ3AttributeTypeNumTypes
  111. } TQ3AttributeTypes;
  112.  
  113. typedef TQ3ElementType TQ3AttributeType;
  114.  
  115.  
  116. /******************************************************************************
  117.  **                                                                             **
  118.  **                                Attribute Drawing                             **
  119.  **                                                                             **
  120.  *****************************************************************************/
  121.  
  122. QD3D_EXPORT TQ3Status Q3Attribute_Submit(
  123.     TQ3AttributeType        attributeType,
  124.     const void                *data,
  125.     TQ3ViewObject            view);
  126.  
  127.  
  128. /******************************************************************************
  129.  **                                                                             **
  130.  **                            AttributeSet Routines                             **
  131.  **                                                                             **
  132.  *****************************************************************************/
  133.  
  134. QD3D_EXPORT TQ3AttributeSet Q3AttributeSet_New(
  135.     void);
  136.  
  137. QD3D_EXPORT TQ3Status Q3AttributeSet_Add(
  138.     TQ3AttributeSet         attributeSet, 
  139.     TQ3AttributeType        type,
  140.     const void                 *data);
  141.  
  142. QD3D_EXPORT TQ3Boolean Q3AttributeSet_Contains(
  143.     TQ3AttributeSet            attributeSet,
  144.     TQ3AttributeType        attributeType);
  145.  
  146. QD3D_EXPORT TQ3Status Q3AttributeSet_Get(
  147.     TQ3AttributeSet         attributeSet,
  148.     TQ3AttributeType        type,
  149.     void                    *data);
  150.  
  151. QD3D_EXPORT TQ3Status Q3AttributeSet_Clear(
  152.     TQ3AttributeSet         attributeSet,
  153.     TQ3AttributeType        type);
  154.  
  155. QD3D_EXPORT TQ3Status Q3AttributeSet_Empty(
  156.     TQ3AttributeSet         target);
  157.  
  158. /*
  159.  * Q3AttributeSet_GetNextAttributeType
  160.  *
  161.  * Pass in kQ3AttributeTypeNone to get first type
  162.  * kQ3AttributeTypeNone is returned when end of list is reached
  163.  */
  164. QD3D_EXPORT TQ3Status Q3AttributeSet_GetNextAttributeType(
  165.     TQ3AttributeSet         source,
  166.     TQ3AttributeType        *type);        
  167.  
  168. QD3D_EXPORT TQ3Status Q3AttributeSet_Submit(
  169.     TQ3AttributeSet            attributeSet, 
  170.     TQ3ViewObject            view);
  171.  
  172. /*
  173.  * Inherit from parent->child into result
  174.  *    Result attributes are:
  175.  *        all child attributes + all parent attributes NOT in the child
  176.  */
  177. QD3D_EXPORT TQ3Status Q3AttributeSet_Inherit(
  178.     TQ3AttributeSet            parent, 
  179.     TQ3AttributeSet            child, 
  180.     TQ3AttributeSet            result);
  181.  
  182.  
  183. /******************************************************************************
  184.  **                                                                             **
  185.  **                            Custom Element Registration                         **
  186.  **                                                                             **
  187.  *****************************************************************************/
  188.  
  189. /*
  190.  * Element Methods - 
  191.  *
  192.  *         When you create a custom element, you control what structures are 
  193.  *        passed around the API. For example, you may allow the Q3Set_Add call 
  194.  *        take one type of argument, store your element internally in some 
  195.  *        abstract data type, and have the Q3Set_Get call take a different 
  196.  *        argument.
  197.  *
  198.  *        For example:
  199.  *            
  200.  *        There are four calls which at some point will copy an element:
  201.  *
  202.  *        Q3Set_Add (copied from Application memory to QuickDraw3D memory)
  203.  *        Q3Set_Get (copied from QuickDraw3D memory to Application memory)
  204.  *        Q3Object_Duplicate (all elements are copied internally)
  205.  *        Q3AttributeSet_Inherit (all elements are copied internally)
  206.  *
  207.  *         Either CopyAdd or CopyReplace is called during the "_Add" call.
  208.  *            - CopyAdd is destructive and should assume "toElement" is garbage
  209.  *            - CopyReplace is replacing an existing element.
  210.  *
  211.  *         CopyGet is called during the "_Get" call.
  212.  *
  213.  *         CopyDuplicate is called to duplicate an element's internal structure.
  214.  *
  215.  * Attributes Methods - 
  216.  *
  217.  *        For copying data while Inheriting. Element methods are used
  218.  *        at all other times.
  219.  *    
  220.  *         CopyInherit is called to duplicate an element's internal structure 
  221.  *            during inheritance. You should make this as fast as possible.
  222.  *            (for example, if your custom element contains objects, you
  223.  *             should do a Q3Shared_GetReference instead of a Q3Object_Duplicate)
  224.  *            
  225.  *        The ElementDelete method will be called for all of your elements 
  226.  *        copied around via CopyAdd, CopyReplace, CopyDuplicate, and 
  227.  *        CopyInherit.
  228.  *        If CopyGet allocates any memory in it's destination, it is up to the 
  229.  *        application to delete it on its side.
  230.  */
  231. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  232.  
  233. #define kQ3MethodTypeElementCopyAdd            Q3_METHOD_TYPE('e','c','p','a')
  234. #define kQ3MethodTypeElementCopyReplace        Q3_METHOD_TYPE('e','c','p','r')
  235. #define kQ3MethodTypeElementCopyGet            Q3_METHOD_TYPE('e','c','p','g')
  236. #define kQ3MethodTypeElementCopyDuplicate    Q3_METHOD_TYPE('e','c','p','d')
  237. #define kQ3MethodTypeElementDelete            Q3_METHOD_TYPE('e','d','e','l')
  238.  
  239. typedef TQ3Status (*TQ3ElementCopyAddMethod)(    
  240.     const void            *fromAPIElement,            /* element from _Add API call */
  241.     void                *toInternalElement);        /* to new QD3D internal element */
  242.  
  243. typedef TQ3Status (*TQ3ElementCopyReplaceMethod)(
  244.     const void            *fromAPIElement,            /* element from _Add API call */
  245.     void                *ontoInternalElement);        /* replacing QD3D internal element */
  246.  
  247. typedef TQ3Status (*TQ3ElementCopyGetMethod)(
  248.     const void            *fromInternalElement,        /* from QD3D internal element */
  249.     void                *toAPIElement);                /* to _Get API call */
  250.  
  251. typedef TQ3Status (*TQ3ElementCopyDuplicateMethod)(
  252.     const void            *fromInternalElement,        /* from QD3D internal element */
  253.     void                *toInternalElement);        /* to new QD3D internal element */
  254.  
  255. typedef TQ3Status (*TQ3ElementDeleteMethod)(    
  256.     void                *internalElement);
  257.  
  258. QD3D_EXPORT TQ3ObjectClass Q3ElementClass_Register(
  259.      TQ3ElementType        elementType,
  260.     const char            *name,
  261.     unsigned long        sizeOfElement,
  262.     TQ3MetaHandler        metaHandler);
  263.  
  264. QD3D_EXPORT TQ3Status Q3ElementType_GetElementSize(
  265.      TQ3ElementType        elementType,
  266.     unsigned long        *sizeOfElement);
  267.  
  268.  
  269. /******************************************************************************
  270.  **                                                                             **
  271.  **                        Custom Attribute Registration                         **
  272.  **                                                                             **
  273.  *****************************************************************************/
  274.  
  275. #define kQ3MethodTypeAttributeInherit        Q3_METHOD_TYPE('i','n','h','t')
  276. typedef TQ3Boolean        TQ3AttributeInheritMethod;
  277. /* return kQ3True or kQ3False in your metahandler */
  278.  
  279. #define kQ3MethodTypeAttributeCopyInherit    Q3_METHOD_TYPE('a','c','p','i')
  280. typedef TQ3Status (*TQ3AttributeCopyInheritMethod)(
  281.     const void            *fromInternalAttribute,        /* from QD3D internal element */
  282.     void                *toInternalAttribute);        /* to new QD3D internal element */
  283.  
  284. QD3D_EXPORT TQ3XObjectClass Q3AttributeClass_Register(
  285.     TQ3AttributeType    attributeType,
  286.     const char            *creatorName,
  287.     unsigned long        sizeOfElement,
  288.     TQ3XMetaHandler        metaHandler);
  289.  
  290. /*
  291.  *    Version 1.1
  292.  */
  293. #define kQ3MethodTypeAttributeDefault        Q3_METHOD_TYPE('a','s','d','f')
  294. typedef TQ3Status (*TQ3AttributeDefaultMethod)(    
  295.     void                *internalElement);
  296.  
  297. #define kQ3MethodTypeAttributeIsDefault        Q3_METHOD_TYPE('a','i','d','f')
  298. typedef TQ3Boolean (*TQ3AttributeIsDefaultMethod)(    
  299.     void                *internalElement);
  300.     
  301.     
  302. #endif  /*  QD3D_OBSOLETE  */
  303.  
  304.  
  305.  
  306. #define kQ3XMethodTypeElementCopyAdd        Q3_METHOD_TYPE('e','c','p','a')
  307. #define kQ3XMethodTypeElementCopyReplace    Q3_METHOD_TYPE('e','c','p','r')
  308. #define kQ3XMethodTypeElementCopyGet        Q3_METHOD_TYPE('e','c','p','g')
  309. #define kQ3XMethodTypeElementCopyDuplicate    Q3_METHOD_TYPE('e','c','p','d')
  310. #define kQ3XMethodTypeElementDelete            Q3_METHOD_TYPE('e','d','e','l')
  311.  
  312. typedef TQ3Status (*TQ3XElementCopyAddMethod)(    
  313.     const void            *fromAPIElement,            /* element from _Add API call */
  314.     void                *toInternalElement);        /* to new QD3D internal element */
  315.  
  316. typedef TQ3Status (*TQ3XElementCopyReplaceMethod)(
  317.     const void            *fromAPIElement,            /* element from _Add API call */
  318.     void                *ontoInternalElement);        /* replacing QD3D internal element */
  319.  
  320. typedef TQ3Status (*TQ3XElementCopyGetMethod)(
  321.     const void            *fromInternalElement,        /* from QD3D internal element */
  322.     void                *toAPIElement);                /* to _Get API call */
  323.  
  324. typedef TQ3Status (*TQ3XElementCopyDuplicateMethod)(
  325.     const void            *fromInternalElement,        /* from QD3D internal element */
  326.     void                *toInternalElement);        /* to new QD3D internal element */
  327.  
  328. typedef TQ3Status (*TQ3XElementDeleteMethod)(    
  329.     void                *internalElement);
  330.  
  331. QD3D_EXPORT TQ3XObjectClass Q3XElementClass_Register(
  332.      TQ3ElementType        elementType,
  333.     const char            *name,
  334.     unsigned long        sizeOfElement,
  335.     TQ3XMetaHandler        metaHandler);
  336.  
  337. QD3D_EXPORT TQ3Status Q3XElementType_GetElementSize(
  338.      TQ3ElementType        elementType,
  339.     unsigned long        *sizeOfElement);
  340.  
  341.  
  342. /******************************************************************************
  343.  **                                                                             **
  344.  **                        Custom Attribute Registration                         **
  345.  **                                                                             **
  346.  *****************************************************************************/
  347.  
  348. #define kQ3XMethodTypeAttributeInherit        Q3_METHOD_TYPE('i','n','h','t')
  349. typedef TQ3Boolean        TQ3XAttributeInheritMethod;
  350. /* return kQ3True or kQ3False in your metahandler */
  351.  
  352. #define kQ3XMethodTypeAttributeCopyInherit    Q3_METHOD_TYPE('a','c','p','i')
  353. typedef TQ3Status (*TQ3XAttributeCopyInheritMethod)(
  354.     const void            *fromInternalAttribute,        /* from QD3D internal element */
  355.     void                *toInternalAttribute);        /* to new QD3D internal element */
  356.  
  357. QD3D_EXPORT TQ3XObjectClass Q3XAttributeClass_Register(
  358.     TQ3AttributeType    attributeType,
  359.     const char            *creatorName,
  360.     unsigned long        sizeOfElement,
  361.     TQ3XMetaHandler        metaHandler);
  362.  
  363. /*
  364.  *    Version 1.1
  365.  */
  366. #define kQ3XMethodTypeAttributeDefault        Q3_METHOD_TYPE('a','s','d','f')
  367. typedef TQ3Status (*TQ3XAttributeDefaultMethod)(    
  368.     void                *internalElement);
  369.  
  370. #define kQ3XMethodTypeAttributeIsDefault    Q3_METHOD_TYPE('a','i','d','f')
  371. typedef TQ3Boolean (*TQ3XAttributeIsDefaultMethod)(    
  372.     void                *internalElement);
  373.  
  374.  
  375. #ifdef __cplusplus
  376. }
  377. #endif    /* __cplusplus */
  378.  
  379. #if defined(__MWERKS__)
  380.     #pragma enumsalwaysint reset
  381. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  382.     #pragma options enum=reset
  383. #endif
  384.  
  385. #endif /*  QD3DSet_h */
  386.